/* applhelp.p - APPLICATION HELP PROCEDURE                               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/* All rights reserved worldwide.  This is an unpublished work.          */
/*N101*/ /* $Revision: 1.15.1.18 $                                        */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                    */
/* REVISION 1.0      Last Modified:  09/01/86   BY: PML 08               */
/*                                   05/15/86   BY: EMB                  */
/* REVISION: 2.0     LAST MODIFIED:  02/23/87   BY: pml *A30*            */
/* REVISION: 4.0     LAST MODIFIED:  11/28/87   BY: pml                  */
/*                                   12/30/87   BY: WUG *A138*           */
/*                                   01/13/88   BY: WUG *A143*           */
/*                                   05/02/88   BY: emb *A223*           */
/*                                   05/09/88   BY: WUG *A233*           */
/*                                   06/29/88   BY: WUG *A306*           */
/*                                   01/20/89   BY: WUG *A617*           */
/*                                   02/16/89   BY: WUG *B038*           */
/*                                   03/15/89   BY: TJT *A664*           */
/* REVISION: 5.0     LAST EDIT:      05/09/89   BY: WUG *B109*           */
/*                                   06/16/89   BY: WUG *B152*           */
/*                                   09/26/89   BY: MLB *B316*           */
/*                                   12/29/89   BY: flm *B478*           */
/*                                   01/19/90   BY: WUG *B513*           */
/*                                   02/22/90   BY: WUG *B580*           */
/*                                   02/22/90   BY: WUG *B584*           */
/*                                   02/22/90   BY: WUG *B586*           */
/*                                   02/26/90   BY: WUG *B588*           */
/*                                   03/20/90   BY: emb *B628*           */
/* REVISION: 6.0      LAST MODIFIED: 06/29/90   BY: WUG *D043*           */
/*                                   07/06/90   BY: WUG *D046*           */
/*                                   08/23/90   BY: WUG *D054*           */
/*                                   10/12/90   BY: WUG *D097*           */
/*                                   10/29/90   BY: WUG *D152*           */
/*                                   03/12/91   BY: emb *D420*           */
/*                                   06/03/91   BY: WUG *D675*           */
/*                                   06/11/91   BY: emb *D692*           */
/*                                   06/27/91   BY: emb *D730*           */
/*                                   07/22/91   BY: WUG *D779*           */
/*                                   07/26/91   BY: pml *D793*           */
/* REVISION: 7.0      LAST Modified: 08/23/91   By: jcd *F004*           */
/*                                   11/11/91   BY: pml *F035*           */
/*                                   11/14/91   BY: WUG *D931*           */
/*                                   05/22/92   BY: sas *F454*           */
/*                                   06/23/92   By: jcd *F679*           */
/* Revision: 7.3      Last modified: 01/25/93   By: mpp *G587*           */
/*                                   01/27/93   By: rwl *G600*           */
/*                                   07/01/93   By: rwl *GC91*           */
/* Revision: 7.4      Last modified: 11/30/93   By: rwl *H252*           */
/*                                   03/02/94   By: rwl *H223*           */
/*                                   06/09/94   By: rmh *FO60*           */
/*                                   12/07/94   By: rmh *FU42*           */
/* REVISION: 7.4      LAST MODIFIED: 12/21/94   BY: yep *F0BB*           */
/* REVISION: 7.4      LAST MODIFIED: 01/30/95   BY: ame *G0DC*           */
/* REVISION: 7.4      LAST MODIFIED: 02/01/95   BY: rmh *F0G9*           */
/* REVISION: 7.4      LAST MODIFIED: 02/17/95   BY: yep *F0JF*           */
/* REVISION: 7.4      LAST MODIFIED: 03/27/95   BY: jzs *G0FB*           */
/* REVISION: 7.4      LAST MODIFIED: 05/17/95   BY: str *G0MY*           */
/* REVISION: 7.4      LAST MODIFIED: 08/04/95   BY: str *G0TK*           */
/* REVISION: 7.4      LAST MODIFIED: 08/22/95   BY: str *G0V7*           */
/* Revision: 8.5           Modified: 01/15/96   By: kws *J0BW*           */
/* Revision: 8.5      Last Modified: 11/07/95   By: kws *J090*           */
/* Revision: 8.5      Last Modified: 03/05/96   By: aed *J0DL*           */
/* REVISION: 8.5      LAST MODIFIED: 04/30/96   BY: *J0KZ* Markus Barone */
/* REVISION: 8.5      LAST MODIFIED: 05/20/96   BY: rkc *G1VJ*           */
/* REVISION: 8.5      LAST MODIFIED: 07/03/96   BY: jpm *J0XJ*           */
/* REVISION: 8.5      LAST MODIFIED: 07/24/96   BY: jpm *J0WN*           */
/* REVISION: 8.5      LAST MODIFIED: 08/01/96   BY: *J136* Markus Barone */
/* REVISION: 8.5      LAST MODIFIED: 01/29/97   BY: *J1G5* Jean Miller   */
/* REVISION: 8.6      LAST MODIFIED: 03/14/97   BY: *K06Q* Srinivasa(SVS)*/
/* REVISION: 8.5      LAST MODIFIED: 05/09/97   BY: *J1PW* Bill Pedersen */
/* REVISION: 8.5      LAST MODIFIED: 03/09/98   BY: *J2G8* Jean Miller   */
/* REVISION: 8.6E     LAST MODIFIED: 08/25/98   BY: *L07B* Jean Miller   */
/* REVISION: 8.6E     LAST MODIFIED: 09/11/98   BY: *L093* Jean Miller   */
/* REVISION: 8.6E     LAST MODIFIED: 09/25/98   BY: *J2Z2* Vijaya Pakala */
/* REVISION: 9.0      LAST MODIFIED: 03/29/00   BY: *M0LD* Raphael T     */
/* REVISION: 9.1      LAST MODIFIED: 08/11/00   BY: *N0KK* jyn           */
/* REVISION: 9.1      LAST MODIFIED: 09/13/00   BY: *N0W0* BalbeerS Rajput*/
/* Revision: 1.15         BY: Anil Sudhakaran  DATE: 04/03/01  ECO: *M0NS* */
/* Revision: 1.15.1.1     BY: Chris Green      DATE: 07/27/01  ECO: *N101* */
/* Revision: 1.15.1.2     BY: Sathish Kumar    DATE: 07/27/01  ECO: *M1G7* */
/* Revision: 1.15.1.3     BY: Tony Winter      DATE: 09/22/01  ECO: *N18V* */
/* Revision: 1.15.1.7     BY: Jean Miller      DATE: 03/06/02  ECO: *N1C5* */
/* Revision: 1.15.1.17.1.1   BY: Jean Miller      DATE: 03/18/02  ECO: *N1DQ* */
/* $Revision: 1.15.1.18 $  BY: John Pison      DATE: 04/28/02  ECO: *N1HN* */
/***************************************************************************/

/*N1HN*/ /*The contents of applhelp.p has been moved to gpapphlp.p.  This*/
/*N1HN*/ /*was done to keep applhelp.p as small as possible to increase*/
/*N1HN*/ /*performance for Desktop 2*/

/*N1HN*/ define shared variable global_user_lang_dir like lng_mstr.lng_dir.

define variable isMobile as logical initial no.
define variable pgmlevel as integer initial 1.
REPEAT WHILE (PROGRAM-NAME(pgmlevel) <> ?):
    IF INDEX(PROGRAM-NAME(pgmlevel), "mfx~.p") <> 0 THEN DO:
        isMobile = yes.
        leave.
    END.
    pgmlevel = pgmlevel + 1.
END.

/*N1HN*/ if not {gpiswrap.i} then do:
             if isMobile = no then do:  
                 {gprun.i ""gpapphlp.p""}
             end.
             else do:
                 {gprun.i ""gpapphlpx.p""}
             end.
/*N1HN*/ end.
/*N1HN*/ else do:
/*N1HN*/    {mfww01.i}
/*N1HN*/ end.

/*N1HN**************BEGIN DELETE****************************
*          {mfdeclre.i}
* /*N0W0*/ {cxcustom.i "applhelp.p"}
 *
* /*F679*/ {mf1.i}
 *
* /*G587*/ {gpfieldv.i} /*var defs for gpfield.i*/
* /*F679*  Start
*  *       define shared variable help_exec like mnd_exec.
*  * /*D793*/ define shared variable mfguser as character.
*  *       define shared variable printdefault as character.
*  *       define shared variable printdefaultlevel as integer.
*  *   /*F035*/ define /*F454 new */  shared variable window_recid as recid.
*  */
*
* /*N18V*/ /* The following include file determines if the widget walker code */
* /*N18V*/ /* is active and fires any relevant triggers associated to it.     */
* /*N18V*/ /* It then returns to the calling procedure.                       */
* /*N18V*/ /* If the widget walker code is not persistent in memory then it   */
* /*N18V*/ /* will continue with normal applhelp functionality. This negates  */
* /*N18V*/ /* the need for shared variables.                                  */
*
* /*N18V*/ {mfww01.i} /* Widget walker code */
*
*          define variable oldtitle like dtitle.
*          define variable oldstatus like ststatus.
*          define variable help_text as character format "X(70)".
*          define variable found as integer.
*          define shared variable pass as character format "X(12)".
*
* /*F0BB*/ define shared variable cut_paste as character format "X(70)" no-undo.
*          define variable run_file as character.
*          define variable help_file as character.
*          define variable dir_nbr like mnd_nbr.
*          define variable canrun like mnd_canrun.
*          define variable fkey like ufd_fkey.
*          define variable exec like ufd_exec.
*          define variable i as integer.
*          define variable lastprintdefault as character.
*          define variable lastexecname as character.
*          define variable thismenu as character.
*          define variable thisselection as integer.
*          &IF "{&WINDOW-SYSTEM}" = "TTY":U &THEN                         /*M0LD*/
*            define new shared variable tmpthismenu as character NO-UNDO. /*M0LD*/
*            define new shared variable tmpthisselection                  /*M0LD*/
*                       as integer NO-UNDO.               /*M0LD*/
*          &ENDIF                                                         /*M0LD*/
*          define buffer mnddet for mnd_det.
*          define variable passnbr as character.
* /*FO60*/ define variable last_global_addr like global_addr.
* /*FO60*/ define variable last_global_loc like global_loc.
* /*FO60*/ define variable last_global_lot like global_lot.
* /*FO60*/ define variable last_global_part like global_part.
*          define variable last_global_ref like global_ref.
* /*FO60*/ define variable last_global_site like global_site.
*          define variable last_global_type like global_type.
*          define variable last_global_lang like global_lang.
*          define new shared variable flhdesc like flh_desc.
*          define variable call_pgm_name as character.
*          define variable frame_field_name as character.
* /*F035*/ define new shared variable uid as character.
* /*F035*/ define variable fseq like ufd_seq.
*
* /*F679*/ define variable can_do_menu as logical.
* /*F679*/ define variable group_indx as integer.
* /*G600*/ define variable tmpstr as character.
*
* /*GC91*/ define variable user_excluded like mfc_logical.
* /*GC91*/ define variable tmp_canrun as character.
* /*J0BW*/ define variable pgm-label  as character no-undo.
* /*J0DL*/ define variable tmp-dtitle as character no-undo.
* /*J1G5*/ define variable c-execname like execname.
* /*K06Q*/ define variable apm-ex-sub as character format "x(24)" no-undo.
* /*K06Q*/ define variable complete as logical no-undo.
* /*J1PW*/ define variable l-is-lookup   as logical   no-undo.
* /*J1PW*/ define variable c-lookup-name as character no-undo.
* /*J1PW*/ define variable h-brwgen      as handle    no-undo.
* /*L07B*/ define variable flh-exec   like flh_mstr.flh_exec no-undo.
* /*N1DQ*/ define variable l-batch-del   as logical no-undo initial no.
*
*          /* Function prototype to check if batch delete enabled */
* /*N1DQ* /*M0NS*/ FUNCTION batchDeleteEnabled returns logical forward. */
*
*          lastexecname = execname.
*          lastprintdefault = printdefault.
* /*FO60*/ last_global_addr = global_addr.
* /*FO60*/ last_global_loc = global_loc.
* /*FO60*/ last_global_lot = global_lot.
* /*FO60*/ last_global_part = global_part.
*          last_global_ref = global_ref.
* /*FO60*/ last_global_site = global_site.
*          last_global_type = global_type.
*          last_global_lang = global_lang.
*          global_ref = "".
*          global_type = "".
*          global_lang = "".
*          frame_field_name = frame-field.
*
*          &IF "{&WINDOW-SYSTEM}" = "TTY":U &THEN                         /*M0LD*/
*            assign tmpthismenu = ""                                      /*M0LD*/
*                   tmpthisselection = 0.                                 /*M0LD*/
*          &ENDIF                                                         /*M0LD*/
*
* /*K06Q*/ /*V8-*/
* /*K06Q*/ find first soc_ctrl no-lock no-error.
* /*K06Q*/ if soc_apm then do:
* /*K06Q*/    assign apm-ex-sub = "if/"
* /*K06Q*/    complete = no.
* /*K06Q*/    {gprunex.i
*            &module   = 'APM'
*            &subdir   = apm-ex-sub
*            &program  = 'ifhelp.p'
*            ?ms   = "(input-output complete)" }
* /*K06Q*/    if complete then return.
* /*K06Q*/ end.
* /*K06Q*/ /*V8+*/
*          main: do:
*          /*CHECK IF FUNCTION KEY F-13 THRU F-39 OR F-6/Ctrl-P WAS PRESSED */
* /*G0FB*/ if (lastkey >= 313 and lastkey <= 339) /*H223*/
* /*V8-*/          or (lastkey = 306) or (lastkey = 16)  /*V8+*/ /*G0FB* not for GUI*/
*          then do:
*             if lastkey > 300 then
*             fkey = lastkey - 300.
*             else fkey = lastkey - 10.
*             oldtitle = dtitle.
*             oldstatus = ststatus.
*             uid = global_userid.
*             find first ufd_det where ufd_userid = uid
*             and (ufd_fkey = fkey or fkey = 6)
*             no-lock no-error.
*             if not available ufd_det then uid = "".
*             window_recid = 0.
*
* /*N1C5*/    if false then do:
* /*N1C5*/       {gprun.i ""mglu068.p""}
* /*N1C5*/    end.
*
* /*G0FB*//*V8-*/
*             user_menu: do:
*                /*CHECK FOR F6 - SHOW USER MENU */
*                if fkey = 6 then do:
*                  repeat:
*                     window_row = 3.
*                     window_down = 6.
* /*N1C5*             {gprun.i ""swusm.p""} */
* /*N1C5*/            run get-brwgen in THIS-PROCEDURE.
* /*N1C5*/            if valid-handle(h-brwgen) then
* /*N1C5*/               run run-lookup in h-brwgen
* /*N1C5*/                  (input "mg068",
* /*N1C5*/                   output window_recid).
*                     if (window_recid <> 0 and window_recid <> ?) then do:
*                        find ufd_det where recid(ufd_det) = window_recid
 *           no-lock no-error.
*                        fkey = ufd_fkey.
*                        fseq = ufd_seq.
*                        leave user_menu.
*                     end.
*         /*PRESSED F4 FROM USER MENU - LEAVE OR DISPLAY DEFAULT KEYS */
* /*G0TK*/            else if uid = "" or
* /*G0TK*/            can-find(first ufd_det where ufd_userid = "") = false
* /*G0TK*/            then do:
* /*G0TK*/               hide message no-pause.
* /*G0TK*/               leave main.
* /*G0TK*/            end.
* /*G0TK*/            uid = "".
*
* /*G0TK*
*  *
* /*FU42*/            else uid = "".
* /*FU42*/            if uid = "" then leave main.
* /*FU42*
*  *                  else if uid = "" then leave main.
*  *                  uid = "".
*  *FU42*/
*  *
*  *G0TK*/
*                  end. /*repeat*/
*                end.  /* if fkey = 6*/
*             end. /* user_menu */
* /*G0FB*//*V8+*/
*
*             eachentry:
*             for each ufd_det no-lock where ufd_userid = uid
*             and ufd_fkey = fkey and(ufd_seq = fseq or window_recid = 0):
*                dir_nbr = ".".
*                canrun = "*".
*                exec = ufd_exec.
*
*                /* DOES THIS FUNCTION KEY TAKE US TO A MENU? */
*                if can-find(first mnd_det where mnd_nbr = exec) then do:
*                  {mfmsg03.i 5001 3 exec """" """"}
*                  pause.
*                  next.
*                end.
*
*                find mnd_det where mnd_nbr = ufd_nbr and mnd_select = ufd_select
*                no-lock no-error.
*                if available mnd_det then do:
*                  dir_nbr = mnd_nbr.
*                  canrun = mnd_canrun.
*                end.
*
*                execname = ufd_exec.
 *
*                run_file = execname.
*                if index(run_file,".p") > 0 then
*                  run_file = substr(run_file,1,index(run_file,".p") - 1).
* /*J0BW*/       else if index(run_file,".W":U ) > 0 then
* /*J0BW*/          run_file = substr(run_file,1,index(run_file,".W":U) - 1).
*                run_file = global_user_lang_dir + substr(run_file,1,2) +
*                 "/" + run_file.
 *
*                if search(run_file + ".r") = ?
*                and search(run_file + ".p") = ?
* /*J0BW*/       and search(run_file + ".w":U ) = ?
 *           then do:
*                  /* NOW LOOK IN THE MAIN DIRECTORY */
*                  run_file = execname.
*                  if index(run_file,".p") > 0 then
*                     run_file = substr(run_file,1,index(run_file,".p") - 1).
*                  if index(run_file,".w") > 0 then
*                     run_file = substr(run_file,1,index(run_file,".w") - 1).
*                  run_file = global_user_lang_dir + run_file.
*
*                 if search(run_file + ".r") = ?
*                 and search(run_file + ".p") = ?
* /*J0BW*/        and search(run_file + ".w":U) = ?
*                 then do:
* /*H252*/        /* message "Selection F" + string(ufd_fkey) + */
* /*H252*/        /* " (Program " + exec + ") not currently installed.". */
* /*H252*/            {mfmsg03.i 5559 2 "ufd_fkey" "exec" """"}
*                     pause.
*                     next.
*                  end.
*                end.
*
*                dtitle = keylabel(fkey + 300) + "-" + lc (exec).
*
*                /* DO PASSWORD CHECKING                                */
*                /* LOOK AT THIS LEVEL AND MENUS ABOVE IT TO SEE        */
*                /* IF PROTECTED                                        */
*
* /*G0V7**
* .               if available mnd_det then do for mnddet:
* .                 find first mnddet where mnddet.mnd_nbr = mnd_det.mnd_nbr
* .                 and mnddet.mnd_select = mnd_det.mnd_select no-lock no-error.
* .                 repeat while available mnddet and mnddet.mnd_nbr <> "":
* ./*F679*
* . * /*D730*     if not can-do (mnddet.mnd_canrun,pass) then do: */
* . * /*D730*/    if not can-do (mnddet.mnd_canrun + ",!*",pass) then do:
* . * /*D730*        bell. */
* . */
* ./*F679*/            {mfsec.i "mnddet"}
* ./*F679*/            if not can_do_menu then do:
* .                       {mfmsg.i 23 3}
* .                       /* Password does not allow access to this function. */
* .                       undo eachentry , leave eachentry.
* .                    end.
* .                    passnbr = mnddet.mnd_nbr.
* .                    find first mnddet where mnddet.mnd_exec = passnbr
* .                    no-lock no-error.
* .                 end.
* .               end.
* **G0V7*/
* /*G0V7*/       if available mnd_det then do:
* /*G0V7*/          {gprun1.i  ""mfsec.p"" "(input mnd_det.mnd_nbr,
*                                            input mnd_det.mnd_select,
* /*G1VJ*/       /* can display error */     input true,
*                                            output can_do_menu)"
*                   }
* /*G0V7*/          if can_do_menu = false then undo eachentry, leave eachentry.
* /*G0V7*/       end.
*
* /*J0DL*/       dtitle = execname.
*                {mfmenu.i}
*
* /*M1G7*/       /* ALL THE FRAMES WILL BE HIDDEN BY GPWINRUN.P */
* /*M1G7**       hide all. */
*
*                status input "".
*
*                /* GET PRINTER DEFAULT */
*                thismenu = ufd_nbr + "." + string(ufd_select).
*                {mfprdef.i thismenu}
*                &IF "{&WINDOW-SYSTEM}" = "TTY":U &THEN                   /*M0LD*/
*                  assign tmpthismenu = ufd_nbr                           /*M0LD*/
*                         tmpthisselection = ufd_select.                  /*M0LD*/
*                &ENDIF                                                   /*M0LD*/
*
*                /*CHECK FOR A TRANSACTION PENDING */
*                define variable istrans as logical.
*                istrans = yes.
*                do on error undo:
*                  istrans = no.
*                  undo, leave.
*                end.
*                if istrans then do:
*                  {mfmsg.i 2250 2}
*                end.
*
* /*J0BW**      run value(run_file + ".p").  **/
* /*J0BW*/      /* IF THERE IS NO EXPLICIT EXTENSION, ASSUME A ".P" */
* /*J0BW*/      if r-index(execname,".P":U) = 0 and r-index(execname,".W":U) = 0
* /*J0BW*/      then
* /*J0BW*/         execname = substring(execname,1,r-index(execname,".") - 1)
* /*J0BW*/           + ".P":U.
* /*J0BW*/      /* GET THE PROGRAM LABEL */
* /*J0DL*/      tmp-dtitle = dtitle.      /* save it, we may need it */
* /*J0BW*/      {gprun.i 'gpnm2lbl.p' "(INPUT execname, OUTPUT pgm-label)"}
* /*J0DL*/      if session:window-system = "TTY":U then
* /*J0DL*/         dtitle = tmp-dtitle.   /* restore it for CHUI */
* /*J0BW*/      /* RUN PGM USING GPWINRUN, SO WINDOWS ETC. ARE RESET CORRECTLY */
* /*J0BW*/      {gprun.i 'gpwinrun.p' "(INPUT execname, INPUT pgm-label)"}
*
* /*M1G7*/       /* HIDING AND RE-VIEWING OF THE FRAMES IS TAKEN CARE IN */
* /*M1G7*/       /* GPWINRUN.P */
* /*M1G7**       hide all. */
*                status input ststatus.
*
*             end.
*             /* for each ufd_det */
*
*             dtitle = oldtitle.
*             ststatus = oldstatus.
*          end.
*
*          /*F035 - DELETED F6 MASTER  COMMENTS */
*          else
* /*G0FB*//*V8-*/
*
* /***** BEGIN OF ADDED CODE *************J2Z2 *************************/
*    define variable mfdpers-handle as widget-handle no-undo.
*
*             if lastkey = keycode("ESC-TAB":U) then do:
*             run get-program-off-of-stack  in this-procedure
*                 (INPUT-OUTPUT mfdpers-handle,
*                  INPUT "mfdpers":U).
*               if valid-handle(mfdpers-handle) then do:
*                  run p-menu-drill in mfdpers-handle.
*               end.
*             end.
*
* /******* END OF ADDED CODE  ************* J2Z2 *********************/
*
*          if lastkey = keycode("f2") or lastkey = keycode("pf2")
*          or lastkey = keycode("CTRL-W") then do:
*
* /*L07B**************************************************************
*  * /*J1G5*/    c-execname =  substring(execname,1,r-index(execname,".") - 1 ).
*  *
*  *             /* LOOK FOR A PROCEDURE TO EXECUTE */
*  *             find first flh_mstr where flh_field = frame-field
*  *             and flh_call_pgm = execname no-lock no-error.
*  * /*J1G5*/    if not available flh_mstr then
*  * /*J1G5*/    find last flh_mstr where flh_field = frame-field
*  * /*J1G5*/      and index(flh_call_pgm,c-execname) > 0 no-lock no-error.
*  * /*D692*/    if not available flh_mstr then
*  * /*D692*/    find last flh_mstr where flh_field = frame-field
*  * /*G0DC*/ /*D692*/    and execname matches TRIM( flh_call_pgm ) no-lock no-error.
*  * /*G0DC*     add TRIM() function to column name to work around pro v7  */
*  * /*G0DC*     oracle data server short coming in which matches doesn't  */
*  * /*G0DC*     perform with db column serving as the pattern.            */
*  *           if not available flh_mstr then
*  *           find first flh_mstr where flh_field = frame-field
*  *           and flh_call_pgm = ""
*  *           no-lock no-error.
*  *
*  *
*  *           if available flh_mstr
*  * /*D420*/    and flh_exec <> ""
*  *           then do:
*  *             window_row = flh_y.
*  *             window_down = flh_down.
*  *             flhdesc = flh_desc.
*  *********************************************/ /*L07B*/
*
* /*L07B*/    run find-flh-mstr in THIS-PROCEDURE
*               (INPUT execname,
*                INPUT frame-field,
*                OUTPUT flh-exec).
*
* /*L07B*/    if flh-exec <> "" then do:
*                assign
* /*J0DL*/       global_ref = frame-field
* /*J0XJ*/       global-drill-handle = focus.   /*J2Z2*/
*
* /*J1PW*/       run check-for-lookup in THIS-PROCEDURE
* /*L07B* /*J1PW*/   (INPUT flh_exec,  */
* /*L07B*/           (INPUT flh-exec,
* /*J1PW*/            OUTPUT l-is-lookup,
* /*J1PW*/            OUTPUT c-lookup-name).
*
* /*J1PW*/       if l-is-lookup then do:
* /*J1PW*/          run get-brwgen in THIS-PROCEDURE.
* /*J1PW*/          if valid-handle(h-brwgen) then
* /*J1PW*/             run run-lookup in h-brwgen
* /*J1PW*/                 (INPUT c-lookup-name,
* /*J2G8*/                  OUTPUT swindow_recid).
* /*J1PW*/       end.
* /*J1PW*/       else do:
* /*L07B*           {gprun.i flh_exec} */
* /*L07B*/          {gprun.i flh-exec}
* /*J1PW*/       end.
*
*                if frame-value > "" then frame-value = frame-value.
* /*J0WN*/       if swindow_recid <> ? then
* /*J136*/       assign
* /*J0WN*/          window_recid  = swindow_recid
* /*J136*/          swindow_recid = ?.
* /*F0JF*        hide all.         */
*
*             end. /* if flh-exec <> "" */
*
*             if lastkey = keycode("F2") or lastkey = keycode("PF2")
*             or lastkey = keycode("CTRL-W") then do:
*
*       /*F004 Put the display of field and procedure help in separate pgm*/
*                {gpfield.i &field_name = 'flhm_field'}
*
*                if field_found then do:
* /*F0G9*
*  *                {gprun.i ""applhlp2.p""  "(
*  *                                          input frame_field_name
*  *                                          )" }
*  *F0G9*/
* /*J0KZ*/          /* CHANGED FRAME-FIELD TO FRAME_FIELD_NAME */
* /*J090*/          {gprun.i 'gphelp.p':U
*                            "('FIELD_HELP':U,
*                              execname,
*                              input frame_field_name)" }
* /*J090**F0G9*     {gprun.i ""applhlp3.p""  "(
*  *F0G9*                                     input frame_field_name
*  *F0G9*                                     )" }  */
*
*                end.
*                else do:
*                  /* Help database not connected */
*                  {mfmsg.i 5529 4}
*                end.
*
*         /*F004 end */
*
* /*F0JF*/       hide all.
*
*             end.
* /*G0FB*//*V8+*/
* /*G0FB*//*V8!  /* GUI Field Help Engine */
*          if lastkey = keycode("F1") or lastkey = keycode("CTRL-W") then do:
*             {gpfield.i &field_name = 'flhm_field'}
*
*             if field_found then do:
* /*J090*  {gprun.i 'hpfield.p' "(input frame-field)"} */
* /*J090*/ {gprun.i 'gphelp.p':U "('FIELD_HELP':U, execname, input frame-field)" }
*             end.
*             else do:
*                {mfmsg.i 5529 4}
*             end.
* /*G0FB*/ */
*          end.
*
*          else
*
*          /* SHOW FIELD NAME, GENERALIZED CODE AND PASSWORD VALIDATION */
*          if lastkey = keycode("CTRL-F") then do:
* /*N1DQ*/    run isBatchDeleteEnabled
* /*N1DQ*/       (output l-batch-del).
* /*N1DQ*/    if l-batch-del then do:
* /*N1DQ*/       /* Field Name: #.  Batch delete is enabled */
* /*N1DQ*/       {pxmsg.i &MSGNUM=5566 &ERRORLEVEL=1 &MSGARG1=frame-field}
* /*N1DQ*/    end.
* /*N1DQ*/    else do:
*                /* Field name is */
* /*N1DQ*        {mfmsg02.i 5002 1 frame-field} */
* /*N1DQ*/       {pxmsg.i &MSGNUM=5002 &ERRORLEVEL=1 &MSGARG1=frame-field}
* /*N1DQ*/    end.
*             /*G600* Begin - add gpfield and support for 2nd field validation */
*             {gpfield.i &field_name = frame-field}
*             if field_found then do:
*                if index(field_valexp,"gpcode.v") > 0 then do:
*                   tmpstr = trim(field_valexp).
*                   substr(tmpstr,index(tmpstr,"}"),1) = "".
*                   tmpstr = trim(tmpstr).
*                   tmpstr = trim(substr(tmpstr, r-index(tmpstr," "))).
* /*H252*/  /* message "Generalized Codes Validation against field:" tmpstr.*/
* /*H252*/          {mfmsg02.i 5560 1 "tmpstr"}
*                end.
* /*H252*/       else if index(field_valexp,"gpcodsec.v") > 0 then do:
* /*H252*/          tmpstr = trim(field_valexp).
* /*H252*/          substr(tmpstr,index(tmpstr,"}"),1) = "".
* /*H252*/          tmpstr = trim(tmpstr).
* /*H252*/          tmpstr = trim(substr(tmpstr, r-index(tmpstr," "))).
* /*H252*/          {mfmsg02.i 5561 1 "tmpstr"}
* /*H252*/       end.
* /*H252*/       else if index(field_valexp,"gppswd.v") > 0 then do:
* /*H252*/          /* message "Password Validation". */
* /*H252*/          {mfmsg.i 5562 1}
* /*H252*/       end.
*             end.
* /*N101* /*N0W0*/    {&APPLHELP-P-TAG1}   */
*             /*G600* End */
*
* /*N1DQ*/ /*********************
*  *           /* Check if batch delete is supported for the program */
*  * /*M0NS*/    if batchDeleteEnabled() then do:
*  *             /* Batch Delete is enabled */
*  * /*M0NS*/      {pxmsg.i &MSGNUM=4088 &ERRORLEVEL=1}
*  * /*M0NS*/    end.
*  *****************************/
*
* /*N101*/    {&APPLHELP-P-TAG1}
*             pause.
* /*N0W0*/    {&APPLHELP-P-TAG2}
* /*G0MY*/    hide message no-pause.
*         end.
*
*          else  /*CHECK FOR F11 - FOR FIELD VALUE SAVE/RESTORE */
*          if lastkey = keycode("F11") or lastkey = keycode("CTRL-B") then do:
*             if frame-value = "" or frame-value = "  /  /  "
* /*G600*/    or index("000000000000.000000000000",trim(frame-value)) > 0
*             then do:    /* PASTE */
* /*F0BB*
*  *              find qad_wkfl where qad_key1 = mfguser    and
*  *               qad_key2 = "frame-value" no-lock no-error.
*  *              if available qad_wkfl then
*  *              frame-value =  qad_charfld[1].
*  *F0BB*/
* /*F0BB*/        if cut_paste <> "" then
* /*F0BB*/           frame-value = cut_paste.
*             end.
*             else do
* /*D931*/    transaction:   /* CUT */
* /*F0BB*
*  *              find qad_wkfl where qad_key1 = mfguser  and
*  *              qad_key2 = "frame-value" no-error.
*  *              if not available qad_wkfl then create qad_wkfl.
*  *              qad_key1 = mfguser.
*  *              qad_key2 = "frame-value".
*  *              qad_charfld[1] = frame-value.
*  *F0BB*/
* /*F0BB*/        cut_paste = frame-value.
*             end.  /*transaction*/
*          end.
*
* /*H223* Begin - add pgm/field save-restore */
*          else if lastkey = keycode("F12") or lastkey = keycode("CTRL-A")
*          then do:
*             if frame-value = "" or frame-value = "  /  /  "
*             or index("000000000000.000000000000",trim(frame-value)) > 0
*             then do:
*                 find fldf_mstr where fldf_field = frame-field
*                 and fldf_call_pg = execname
*                 and fldf_userid = global_userid no-lock no-error.
*                 if available fldf_mstr then
*                    frame-value =  fldf_value.
*             end.
*             else do transaction:
*                 find fldf_mstr where fldf_field = frame-field
*                 and fldf_call_pg = execname
*                 and fldf_userid = global_userid no-error.
*                 if not available fldf_mstr then create fldf_mstr.
*                 assign
*                 fldf_field = frame-field
*                 fldf_call_pg = execname
*                 fldf_userid = global_userid
*                 fldf_value = frame-value.    /*J2Z2*/
*             end.
*          end.
* /*H223* End */
*
*          end. /* main*/
*          assign execname = lastexecname
*                 printdefault = lastprintdefault
* /*FO60*/        global_addr = last_global_addr
* /*FO60*/        global_loc = last_global_loc
* /*FO60*/        global_lot = last_global_lot
* /*FO60*/        global_part = last_global_part
*                 global_ref = last_global_ref
* /*FO60*/        global_site = last_global_site
*                 global_type = last_global_type
*                 global_lang = last_global_lang.   /*J2Z2*/
*
*          /*end of Main Block*/
*
*          /*********** INTERNAL PROCEDURES ***********/
*
*          PROCEDURE check-for-lookup:
*          /* -----------------------------------------------------------
*           Purpose:     Make sure that this is a lookup and not a
*                        scrolling window
*           Parameters:  p-execname  = the name retrieved from flh_exec
*                        p-is-browse = true, if this is a lookup browse
*                        p-browse-id = the lookup file defininition name
*                                      (such as gp357)
*           Notes:       Added with ECO /*J1PW*/
*          -------------------------------------------------------------*/
*          define input  parameter p-execname  as character no-undo.
*          define output parameter p-is-browse as logical   no-undo.
*          define output parameter p-browse-id as character no-undo.
*          define variable i-id as integer no-undo.
*
*          assign i-id = integer(substring(p-execname, 5, 3, "RAW":U)) no-error.
*
*          p-is-browse = (index(p-execname, "lu":U) = 3) and
*                        not error-status:error.
*          p-browse-id = substring(p-execname, 1, 2, "RAW":U)
*                        + substring(p-execname, 5, 3, "RAW":U).
*
*          END PROCEDURE.
*
*          PROCEDURE find-flh-mstr:
*          /* -----------------------------------------------------------
*           Purpose:     Locate the best flh_mstr record for the current
*                        field name and executable name.
*           Parameters:  p-execname - the menu entry executable name
*                        p-fld-name - the current field
*                        p-flh-exec - flh_exec from found record
*           Notes:
*          -------------------------------------------------------------*/
*          define input  parameter p-execname as character   no-undo.
*          define input  parameter p-fld-name like flh_field no-undo.
*          define output parameter p-flh-exec like flh_exec  no-undo.
*
*          c-execname =  substring(p-execname,1,r-index(p-execname,".") - 1 ).
*
*          /* First, try to find an exact match with no extension*/
*          for first flh_mstr
* /*L093*  fields(flh_call_pgm flh_desc flh_down flh_exec flh_field flh_y) */
*          where flh_field = p-fld-name
*            and entry(1,flh_call_pgm,".") = c-execname no-lock:
*          end.
*
*          /* If not found, try to find a wild-card match on pgm name */
*          if not available flh_mstr then
*          for last flh_mstr
* /*L093*  fields(flh_call_pgm flh_desc flh_down flh_exec flh_field flh_y) */
*          where flh_field = p-fld-name
*            and c-execname matches entry(1,flh_call_pgm,".") no-lock:
*          end.
*
*          /* If still not found, try to find a blank call pgm */
*          if not available flh_mstr then
*          for first flh_mstr
* /*L093*  fields(flh_call_pgm flh_desc flh_down flh_exec flh_field flh_y) */
*          where flh_field = p-fld-name
*            and flh_call_pgm = "" no-lock:
*          end.
*
*          p-flh-exec = "".
*
*          if available flh_mstr and flh_exec <> "" and flh_exec <> "swnull.p"
*          then do:
*             assign
*             window_row = flh_y
*             window_down = flh_down
*             flhdesc = flh_desc
*             p-flh-exec = flh_exec.    /*J2Z2*/
*          end.
*
*          END PROCEDURE.
*
*          PROCEDURE get-brwgen:
*          /* -----------------------------------------------------------
*           Purpose:     Get the handle for the Browse Generator
*           Parameters:  
*           Notes:       Added with ECO /*J1PW*/
*          -------------------------------------------------------------*/
*
*          h-brwgen = session:first-procedure.
*
*          do while valid-handle(h-brwgen):
*             if index(h-brwgen:filename, "gpbrqgen":U) > 0 then leave.
*             h-brwgen = h-brwgen:next-sibling.
*          end.
*
*          return "".
*
*          END PROCEDURE.
*
*          /****************  BEGIN OF J2Z2   **********************************/
*          PROCEDURE get-program-off-of-stack:
*          /*------------------------------------------------------------------------------
*          Purpose:  To retrieve the memory pointer to the location of a program name.
*          Parameters:  Program-handle - pointer to program location
*                       Prog-name      - program name, no extension
*                                        (example:  mfdpers or gpbrqgen)
*          Notes:  This is a generic procedure for retrieving a memory
*                  pointer to a specific program on the memory stack.
*          ------------------------------------------------------------------------------*/
*          define input-output parameter program-handle as widget-handle no-undo.
*          define input        parameter prog-name      as character     no-undo.
*
*           program-handle = session:first-procedure.
*           do while valid-handle(program-handle):
*              if index(program-handle:file-name, prog-name) > 0 then
*                 leave.
*              program-handle = program-handle:next-sibling.
*           end.
*          END PROCEDURE.
*         /**********************   END OF J2Z2      ***************************/
*
*          /* Function batchDeleteEnabled checks whether the menu procedure
*           * Supports batch delete functionality.  Specifically, it checks
*           * Whether the window contains a widget with name "batchdelete" */
*
* /*N1DQ*/ /****************************************
* /*M0NS*/ FUNCTION batchDeleteEnabled returns logical.
*
* /*M0NS*/ define variable thisFrame as handle no-undo.
* /*M0NS*/ define variable thisWidget as handle no-undo.
*
*          /* Find first frame of default window */
* /*M0NS*/ assign
* /*M0NS*/    thisFrame = current-window /* static window of PROGRESS session */
* /*M0NS*/    thisFrame = thisFrame:FIRST-CHILD /* first frame of window */
* /*M0NS*/    .
*
*          /* Loop through all frames of window */
* /*M0NS*/ do while valid-handle(thisFrame):
*
*             /* Check all widgets in frame for batchdelete field */
* /*M0NS*/    assign
* /*M0NS*/       thisWidget = thisFrame:FIRST-CHILD /* field-group of frame */
* /*M0NS*/       thisWidget = thisWidget:FIRST-CHILD /* first field in frame */
* /*M0NS*/       .
* /*M0NS*/    do while valid-handle(thisWidget):
*                /* Return positive value if batchdelete found */
* /*M0NS*/       if thisWidget:NAME = "batchdelete":U then return true.
* /*M0NS*/       thisWidget = thisWidget:NEXT-SIBLING.
* /*M0NS*/    end. /* do while valid-handle(thisWidget) */
*
*             /* Go to next frame */
* /*M0NS*/    thisFrame = thisFrame:NEXT-SIBLING.
*
* /*M0NS*/ end. /* do while valid-handle(thisFrame) */
*
*          /* If no batchdelete found, return empty-handed */
* /*M0NS*/ return false.
*
* /*M0NS*/ END FUNCTION. /* batchDeleteEnabled */
* *******************/
*
* /*N1DQ*/ PROCEDURE isBatchDeleteEnabled:
*
* /*N1DQ*/ define output parameter pIsEnabled as logical initial no no-undo.
*
* /*N1DQ*/ define variable thisFrame as handle no-undo.
* /*N1DQ*/ define variable thisWidget as handle no-undo.
*
*          /* Find first frame of default window */
* /*N1DQ*/ assign
* /*N1DQ*/    thisFrame = current-window /* static window of PROGRESS session */
* /*N1DQ*/    thisFrame = thisFrame:FIRST-CHILD /* first frame of window */
* /*N1DQ*/    .
*
*          /* Loop through all frames of window */
* /*N1DQ*/ do while valid-handle(thisFrame):
*
*             /* Check all widgets in frame for batchdelete field */
* /*N1DQ*/    assign
* /*N1DQ*/       thisWidget = thisFrame:FIRST-CHILD /* field-group of frame */
* /*N1DQ*/       thisWidget = thisWidget:FIRST-CHILD /* first field in frame */
* /*N1DQ*/       .
* /*N1DQ*/    do while valid-handle(thisWidget):
*                /* Return positive value if batchdelete found */
* /*N1DQ*/       if thisWidget:NAME = "batchdelete" then
*                   pIsEnabled = true.
* /*N1DQ*/       thisWidget = thisWidget:NEXT-SIBLING.
* /*N1DQ*/    end. /* do while valid-handle(thisWidget) */
*
*             /* Go to next frame */
* /*N1DQ*/    thisFrame = thisFrame:NEXT-SIBLING.
*
* /*N1DQ*/ end. /* do while valid-handle(thisFrame) */
*
* /*N1DQ*/ END PROCEDURE.
***********END DELETE**************************************/
